<template>
  <div class="login">
    <div class="my-container">
      <div class="my-title">优印染生产在线</div>

      <div class="my-input">
        <label>账户：</label>
        <input type="text" v-model="user.u_id" />
      </div>

      <div class="my-input">
        <label>密码：</label>
        <input type="password" v-model="user.u_pwd" />
      </div>

      <div class="my-button">
        <button @click="login">登录</button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "login",
  data() {
    return {
      user: {
        u_id: "",
        u_pwd: ""
      }
    };
  },
  methods: {
    login() {
      if (!this.user.u_id || this.user.u_id.length == 0) {
        this.$message.error("请填写账号");
        return;
      }
      if (!this.user.u_pwd || this.user.u_pwd.length == 0) {
        this.$message.error("请填写密码");
        return;
      }
      this.$axios.post('safty/login', this.user)
        .then(response => {
            let result = response.data;
            if (result.success) {
              this.$message.success({
                message: result.message,
                onClose: () => {
                  this.$router.push("/home");
                }
              });
            } else {
              this.$message.error(result.message);
            }
      });
    },
    
  },
  mounted() {}
};
</script>

<style scoped>
.login {
  height: 100%;
  margin: 0px;
  padding: 0px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.my-container {
  border: 1px solid #dddddd;
  width: 800px;
  height: 450px;

  margin-bottom: 6%;

  display: flex;
  flex-direction: column;
  align-items: center;

  box-shadow: 0px 0px 10px 1px #dddddd;

  border-radius: 5px;

  background-color: #ffffff;
}

.my-title {
  font-size: 75px;
  font-weight: bold;
  color: #223399;
  letter-spacing: 16px;
  margin: 50px 0px 20px;

  text-shadow: 10px 10px 9px #aabbff;
}

.my-input {
  position: relative;
  height: 40px;
  width: 300px;
  margin: 5px 0px;
}

.my-input > label {
  box-sizing: border-box;

  position: absolute;

  width: 60px;
  height: 40px;
  line-height: 40px;

  letter-spacing: 2px;
  padding-left: 5px;

  color: #666666;
}

.my-input > input {
  box-sizing: border-box;

  padding-left: 60px;

  outline: none;
  border: 1px solid #dddddd;
  border-radius: 5px;
  height: 100%;
  width: 100%;
}

.my-button {
  position: relative;
  height: 40px;
  width: 300px;
  margin: 15px 0px;
}

.my-button > button {
  box-sizing: border-box;

  outline: none;
  border: 1px solid #dddddd;
  border-radius: 5px;
  height: 100%;
  width: 100%;
  background: #fefefe;

  color: #666666;

  letter-spacing: 15px;
}

.my-button > button:hover {
  background-color: #7088ff;
  color: #ffffff;
}

.my-button > button:active {
  background-color: #7088ff;
  color: #ffffff;
  box-shadow: 0 0 6px 1px #7088ff;
  outline: none;
  border: none;
  font-weight: bolder;
}
</style>